/**
 * Created with IntelliJ IDEA.
 * User: aermakov
 * Date: 23.05.13
 * Time: 15:21
 * To change this template use File | Settings | File Templates.
 */

Ext.ns('GrailsCompany.form');

GrailsCompany.form.FormButton = Ext.extend(Ext.Button, {
    getBubbleTarget: function () {
        if (!this.formPanel) {
            this.formPanel = this.findParentBy(function (container) {
                return container.crudacceptable;
            });
        }
        return this.formPanel;
    },
    initComponent: function () {
        Ext.apply(this, {
            bubbleEvents: ['action'],
            listeners: {
                click: function (obj, args) {
                    this.fireEvent('action', this.action);
                }
            }
        });

        GrailsCompany.form.FormButton.superclass.initComponent.apply(this, arguments)

        this.addEvents({'action': true});
    }
});
Ext.reg('formbutton', GrailsCompany.form.FormButton);